package com.example.distinguish_server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.distinguish_server.entity.PhotoGallery;
import com.example.distinguish_server.mapper.PhotoGalleryMapper;
import com.example.distinguish_server.service.PhotoGalleryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xg
 * @since 2023-09-19
 */
@Service
public class PhotoGalleryServiceImpl extends ServiceImpl<PhotoGalleryMapper, PhotoGallery> implements PhotoGalleryService {

    public void add(PhotoGallery photogallery){
        if (photogallery == null){
            return;
        }
        int insert = baseMapper.insert(photogallery);
        System.out.println(insert);
    }

    @Override
    public List<PhotoGallery> inquire(int docId) {
        System.out.println(docId +" DocId");
        QueryWrapper<PhotoGallery> wrapper = new QueryWrapper<>();
        //添加查询值  docId
        List<PhotoGallery> photogalleries = baseMapper.selectList(wrapper);
        return photogalleries;
    }

    @Override
    public boolean compare(PhotoGallery photogallery) {
        QueryWrapper<PhotoGallery>  wrapper = new QueryWrapper<>();
        wrapper.eq("name",photogallery.getName());
        wrapper.eq("Pleft",photogallery.getPleft());
        wrapper.eq("Ptop",photogallery.getPtop());
        wrapper.eq("Pright",photogallery.getPright());
        wrapper.eq("Pbottom",photogallery.getPbottom());
        //添加查询值
        PhotoGallery photogallery1 = baseMapper.selectOne(wrapper);
        if(photogallery1 == null){
            return false;
        } else {
            return true;
        }

    }
}

